// 1. 引入
const bcryptjs = require("bcryptjs");

// 2. 加密方法  bcryptjs.hashSync(要加密的内容, 盐值 | 数字10)
const passwrod = "123456";
const hashPassword = bcryptjs.hashSync(passwrod, 10);

console.log(hashPassword);

// $2a$10$I7mHyyBhDgxvFdKd5QkoUe37gWjAIVblcwy8DFs0dVDvCHOoOtRpe

// $2a$10$VsxUkQKmCwSsbqTwq.q44Oa.i7Qa6fSLJpovAsFgRa889LSvK7zxO

// 3. 解密    bcryptjs.compareSync(明文的内容, 之前生成的密文内容)
const isOk = bcryptjs.compareSync(
  passwrod,
  "$2a$10$VsxUkQKmCwSsbqTwq.q44Oa.i7Qa6fSLJpovAsFgRa889LSvK7zxO"
);

console.log("是否匹配", isOk);
